package com.example.mam.service.impl;

import com.example.mam.entity.User;
import com.example.mam.exception.BizException;
import com.example.mam.exception.BizExceptionEnum;
import com.example.mam.mapper.UserMapper;
import com.example.mam.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author muncie [muncie.hoo@qq.com]
 */
@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserMapper userMapper;

    @Override
    public Long addUser(User user) {
        if (userMapper.saveUser(user) != 1) {
            throw new BizException(BizExceptionEnum.DB_UPDATE_RESULT_ERROR);
        }
        return user.getId();
    }

    @Override
    public User getUserById(Long currentUserId) {
        return userMapper.getUserById(currentUserId);
    }
}
